import React, { useEffect, useState } from 'react'
import './index.scss'
import ReactDOM from 'react-dom'
export default function Loading(props) {
  return (
    <div className="container">
      <div className="loading"></div>
    </div>
  )
}

export function loading(time) {
  const div = document.createElement('div')
  document.body.appendChild(div)

  ReactDOM.render(<Loading time={time}></Loading>, div)

  function close() {
    ReactDOM.unmountComponentAtNode(div)
    if (div && div.parentNode) {
      div.parentNode.removeChild(div)
    }
  }
  // setTimeout(() => {
  //   close()
  // }, 1500)
  return {close}
}